<?
require("config.php");

$location_status .= "| Edit";
$show_backnav = "ban_menu";
$menuname = NULL;
$menutarget = NULL;

if (NULL!=$action){


	if ($Picture_name=="" || $Picture_name==NULL) $Picture_name=$old_Picture;

	if ($remove_Picture=="ture") $Picture_name=NULL;

	$page='';
	if ($chk_H=='1') $page.='H|';
	if ($chk_CO=='1') $page.='CO|';
	if ($chk_CU=='1') $page.='CU|';
	if ($chk_D=='1') $page.='D|';
	if ($chk_PC=='1') $page.='PC|';
	if ($chk_P=='1') $page.='P|';
	if ($chk_S=='1') $page.='S|';
	if ($chk_T=='1') $page.='T|';
	
   $field = array(
	"name", 
	"picture",
    "publish",
	"page",
	"pos",
	"product"
	);


   $content = array(
	$name,
	$Picture_name,
	$Publish,
	$page,
	$pos,
	$product);

	$exp = "id=$id";

   myUpdate($table,$field,$content,$exp);

	$dir = "med_ban/";

	if ($Picture&&$Picture_name) myUpload($Picture,$Picture_name,$dir);


   header("location:" . $rela_path . "share/msg.php?v=66");

   exit();

}else{

  if (!checkRecord($table,$id)){

	header("location:" . $rela_path . "share/msg.php?v=9002");

	exit();
  
  }

}


$Query = "SELECT 
code,
name, 
picture,
publish,
page,
pos,
product
FROM $table WHERE id=$id LIMIT 1";

$r=myQuery($Query);

$Code=$r[0][0];
$name=$r[0][1];
$Picture=$r[0][2];
$Publish=$r[0][3];
$page=$r[0][4];
$pos=$r[0][5];
$product=$r[0][6];


require($rela_path . "inc/header.php");
require($rela_path . "bin/date.php");

$Query="select id,code,name from pro_basic where publish='1' order by id desc;";
$r=myQuery($Query);
$select='';
for ($i=0 ; $i<count($r) ; $i++) {
	if ($product==$r[$i][0]) $s=' selected'; else $s='';
	$select.='<option value="'.$r[$i][0].'"'.$s.'>'.$r[$i][1].'-'.$r[$i][2].'</option>';
}

?>



<form action="" method="post" enctype="multipart/form-data" name="form1">
<input name="action" type="hidden" value="edit">
<input name="id" type="hidden" value="<?print($id)?>">
<input name="old_Picture" type="hidden" value="<?print($Picture)?>">




<table width="95%" border="0" align="center">
  <tr> 
    <td valign="top"> <table border="0" cellspacing="5" cellpadding="1">
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td class="tdheader">Code : </td>
            <td><?print($Code)?></td>
          </tr>
          <tr> 
            <td class="tdheader">Name :</td>
            <td><input type="text" class="text" name="name" size="56" value="<?print($name)?>"></td>
          </tr>
          <tr> 
            <td class="tdheader">Picture :</td>
            <td><?loadImage($Picture,$rela_path . $PIC_DIR. "pro_ban/")?>
			<?removeImage($Picture,"remove_Picture")?>
			<input type="file" class="text" name="Picture" size="45"> </td>
          </tr>
          <tr> 
            <td class="tdheader">Publish :</td>
            <td> 
              <?if ($Publish=="1") {?>
              <input type="radio" name="Publish" value="1" checked>
              yes 
              <input type="radio" name="Publish" value="0">
              no 
              <?}else{?>
              <input type="radio" name="Publish" value="1">
              yes 
              <input type="radio" name="Publish" value="0" checked>
              no 
              <?}?>
            </td>
          </tr>
          <tr>
            <td valign="top" class="tdheader">Show on :</td>
            <td><input name="chk_H" type="checkbox" id="chk_H" value="1" <? if (substr_count($page,'H|')) echo 'checked'; ?>>
              Home
                <br>
                <input name="chk_CO" type="checkbox" id="chk_CO" value="1" <? if (substr_count($page,'CO|')) echo 'checked'; ?>>
                Contact             
                <br>
                <input name="chk_CU" type="checkbox" id="chk_CU" value="1" <? if (substr_count($page,'CU|')) echo 'checked'; ?>>
                Customer Services             
                <br>
                <input name="chk_D" type="checkbox" id="chk_D" value="1" <? if (substr_count($page,'D|')) echo 'checked'; ?>>
                Dealer            
                <br>
                <input name="chk_S" type="checkbox" id="chk_S" value="1" <? if (substr_count($page,'S|')) echo 'checked'; ?>>
                Search             
                 <br>
                <input name="chk_PC" type="checkbox" id="chk_PC" value="1" <? if (substr_count($page,'PC|')) echo 'checked'; ?>>
                Product Category             
               <br>
                <input name="chk_P" type="checkbox" id="chk_P" value="1" <? if (substr_count($page,'P|')) echo 'checked'; ?>>
                Product Detail             
                <br>
                <input name="chk_T" type="checkbox" id="chk_T" value="1" <? if (substr_count($page,'T|')) echo 'checked'; ?>>
                Terms / Privacy</td>
          </tr>
          <tr> 
            <td class="tdheader">Order : </td>
            <td><input name="pos" type="radio" value="1" <? if ($pos==1) echo 'checked'; ?>>
              1st<br>
              <input name="pos" type="radio" value="2" <? if ($pos==2) echo 'checked'; ?>> 
              2nd<br>
              <input name="pos" type="radio" value="3" <? if ($pos==3) echo 'checked'; ?>>
              3rd<br>
              <input name="pos" type="radio" value="4" <? if ($pos==4) echo 'checked'; ?>>
              4th<br>
              <input name="pos" type="radio" value="5" <? if ($pos==5) echo 'checked'; ?>>
              5th</td>
          </tr>
		  <tr> 
            <td class="tdheader">Product :</td>
            <td><select name="product"><?=$select?>
            </select></td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td><input type="image" src="../../images/bt_cancel.gif" onClick="Redirect('ban_menu.php',1);return false;"> <input type="image" src="../../images/bt_save.gif">
            </td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </table>
    </td>

  </tr>
</table>
<br>
<br>
<br>


</form>

<?
require($rela_path . "inc/footer.php");
?>
